<!DOCTYPE html>
<html>
<head lang="en">
    <title>Excel导入</title>
    <LINK rel="stylesheet" href="../static/bootstrap3.3.7/css/bootstrap.css">
    <script src="../static/jquery3.1.1/jquery-3.1.1.min.js" type="text/javascript"></script>
    <script src="../static/bootstrap3.3.7/js/bootstrap.min.js" type="text/javascript"></script>
</head>
<body>
<form role="form" action="/fileUpload" method="post" enctype="multipart/form-data" >
<#--<label for="name">题库</label>
<select class="form-control" id="field" name="fieldid">
    <option value="1">1</option>
    <option value="2">2</option>
</select>-->
    <div class="form-group" >
        <label for="download">下载模板</label><br>
        <a id="download" href="/static/xlsx/questions.xlsx" style="color:rgb(22,22,22);text-decoration: underline;">点击下载</a>
    </div>
    <div class="form-group">
        <label for="inputfile">文件输入</label>
        <input type="file" id="inputfile" name="fileName">
    </div>
    <button type="button" id="button" class="btn btn-default">提交</button>
</form>

</body>
</html>
<script type="text/javascript">
    $(function () {
        $("#button").click(function () {
            var formData = new FormData();
            var file=$(':file').prop('files');
            formData.append("fileName",file[0]);
            $.ajax({
                type:'post',
                url:'/fileUpload',
                data:formData,
                cache: false,
                processData: false,  //tell jQuery not to process the data
                contentType: false,  //tell jQuery not to set contentType
                success:function (data) {
                    console.log(data);
                }
            })
        })
    })
</script>